static char kchars_blank[] = {'\r', '\n', ' ', '\t'};
char* __ustrndup(const char* str, size_t n)
{
    char* dest = _malloc(n + 1);
    if(NULL != dest) {
        memcpy(dest, str, n);
        dest[n] = '\0';
    }

    return dest;
}


int __ustrn_include_char(const char* s, size_t n, char ch)
{
    int ret = 0;
    int i;
    for(i=0; i<n; i++)
    {
        if(ch == s[i])
            return 1;
    }

    return ret;
}


char* __ustrtrim_chars(char* str, char s[], size_t n)
{
    int len_trim_head = 0;
    int len_trim_tail = 0;
    int len_str = 0;

    len_str = strlen(str);
    if(len_str == 0) {
        return str;
    }

    char* tmp = str;
    while(*tmp != '\0' && __ustrn_include_char(s, n, *tmp))
    {
        len_trim_head ++ ;
        tmp ++ ;
    }

    if(len_trim_head == len_str) {
        str[0] = '\0';
        return str;
    }

    tmp = str + (len_str-1);
    while(__ustrn_include_char(s, n, *tmp)) {
        tmp -- ;
        len_trim_tail ++ ;
    }

    len_str -= (len_trim_head + len_trim_tail);
    if(len_trim_head != 0) {
        int i;
        for(i=0; i<len_str; i++)
        {
            str[i] = str[i+len_trim_head];
        }
    }
    
    str[len_str] = '\0';
    
    return str;
}



